package com.lxq.market.listener;

import com.lxq.market.util.Defined;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.io.File;

@WebListener("创建外部路径")
public class MyListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        File file=new File(Defined.external);
        if (!file.exists()) {
            if (file.mkdirs()) {
                System.out.println("创建外部路径成功");
                new File(Defined.userAvatar).mkdirs();
            }else{
                System.err.println("创建外部路径失败");
            }
        }else{
            System.out.println("已存在外部路径");
        }
    }
}
